package com.zf.yichat.api.controller.user;

import com.zf.yichat.api.controller.BaseController;
import com.zf.yichat.api.dto.request.UserIntegralGetRequest;
import com.zf.yichat.model.User;
import com.zf.yichat.service.UserIntegralService;
import com.zf.yichat.service.UserService;
import com.zf.yichat.utils.response.FsPage;
import com.zf.yichat.utils.response.FsResponse;
import com.zf.yichat.vo.IntegralType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 签到积分
 *
 * @author fengsong
 * @date create in 10:36 2019/8/8 2019
 */
@RestController
public class UserIntegralController extends BaseController {


    @Autowired
    private UserService userService;

    @Autowired
    private UserIntegralService userIntegralService;

    /**
     * 获取积分接口
     */
    @PostMapping("user/integral/get")
    public FsResponse sign(@RequestBody UserIntegralGetRequest params) {


        return userIntegralService.getIntegral(IntegralType.valOf(params.getType()), getUserId(), params.getReferId());


    }

    /**
     * 我的积分详情
     */
    @PostMapping("user/integral/info")
    public FsResponse info() {

        return userIntegralService.info(getUserId());


    }

    /**
     * 我的积分详情列表
     */
    @PostMapping("user/integral/info/list")
    public FsResponse list(@RequestBody FsPage params) {
        Long userId = getUserId();

        return userIntegralService.detailInfo(FsPage.init(params.getPageNo(), params.getPageSize()), userId);
    }

}
